package com.googlecode.perfectable.visuable.message.client;

import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.annotate.JsonTypeName;

import com.googlecode.perfectable.prosperable.message.ClientMessage;
import com.googlecode.perfectable.visuable.visual.IdentifiedVisual;

@JsonTypeName("button-push")
public class ButtonPushMessage implements ClientMessage {
	private static final long serialVersionUID = 2524940205203742175L;

	private final String visualIdentifier;

	private ButtonPushMessage(String visualIdentifier) {
		this.visualIdentifier = visualIdentifier;
	}

	public boolean isDirectedAt(IdentifiedVisual context) {
		return context.identifier().equals(this.visualIdentifier);
	}

	@JsonCreator
	public static ButtonPushMessage construct(@JsonProperty("source") String visualIdentifier) {
		return new ButtonPushMessage(visualIdentifier);
	}
}
